#define _CRT_SECURE_NO_WARNINGS 1


#include <iostream>
using namespace std;

int GetMonthDay(int year, int month)
{
    static int MonthDay[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    int Getday = MonthDay[month];
    if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
    {
        Getday++;
    }
    return Getday;
}

void print(int year, int x)
{
    int month = 0;
    int sumday = 0;
    while (sumday < x)
    {
        sumday += GetMonthDay(year, month);
        month++;
    }
    sumday -= GetMonthDay(year, month - 1);
    int day = x - sumday;
    month--;
    printf("%04d-%02d-%02d\n", year, month, day);
}

int main() {
    int year, x;
    while (cin >> year >> x)
    {
        print(year, x);
    }

    return 0;
}




